package ru.isokolov.lib;

public class Declination {
    private static final ThreadLocal<FioDeclination> thFioDeclination = ThreadLocal.withInitial(FioDeclination::new);

    private static FioDeclination fioDeclination() {
        return thFioDeclination.get();
    }

    private static char sexFromBoolean(boolean sex) {
        return sex ? 'м' : 'ж';
    }

    public static String getFIO(String lastName, String firstName, String middleName, boolean sex, int declination) throws ExceptionDeclinationError {
        return fioDeclination().getFIO(lastName, firstName, middleName, sexFromBoolean(sex), declination);
    }

    public static String getInitials(String lastName, String firstName, String middleName, boolean sex, int declination) throws ExceptionDeclinationError {
        return FioComm.getCutFIO(getFIO(lastName, firstName, middleName, sex, declination));
    }
}
